using System;
using System.Collections.Generic;
using System.Text;

namespace GoogleCalendarReminder
{
    /// <summary>
    /// A class which wraps a Google.GData.Extensions.When object and provides
    /// a more user friendly interface.
    /// </summary>
    public class WhenWrapper
    {
        #region Private Data Members

        private Google.GData.Extensions.When _when;
        private ReminderWrapper[] _reminders;

        #endregion

        #region Constructors

        /// <summary>
        /// Creates a new instance of the GoogleCalendarReminder.WhenWrapper class.
        /// </summary>
        /// <param name="when">The when object to wrap.</param>
        /// <exception cref="System.ArgumentNullException">Arguments can't be null.</exception>
        public WhenWrapper(Google.GData.Extensions.When when)
        {
            if (when == null)
                throw new ArgumentNullException("Arguments can't be null.");

            _when = when;

            List<ReminderWrapper> tmpList = new List<ReminderWrapper>(_when.Reminders.Count);

            foreach (Google.GData.Extensions.Reminder reminder in _when.Reminders)
            {
                tmpList.Add(new ReminderWrapper(reminder));
            }

            _reminders = tmpList.ToArray();
        }

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets the end time.
        /// </summary>
        public DateTime EndTime
        {
            get { return _when.EndTime; }
        }

        /// <summary>
        /// Gets the reminders.
        /// </summary>
        public ReminderWrapper[] Reminders
        {
            get { return _reminders; }
        }

        /// <summary>
        /// Gets the start time.
        /// </summary>
        public DateTime StartTime
        {
            get { return _when.StartTime; }
        }

        #endregion
    }
}
